﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AMicroblogAPI;
using AMicroblogAPI.Common;
using AMicroblogAPI.DataContract;

namespace weibo
{
    public partial class DetailFriends : Form
    {
        private string ScreenName;
        public DetailFriends(string name)
        {
            ScreenName = name;
            InitializeComponent();
        }

        private void DetailFriends_Load(object sender, EventArgs e)
        {
            lbName.Text = ScreenName;
            UserInfo ui = AMicroblog.GetUserInfo(ScreenName);
            lbCity.Text = ui.City;
            lbFans.Text = "Fans:" + ui.FollowersCount;
            lbFriends.Text = "Friends:" + ui.FriendsCount;
            lbStatus.Text = "Statuses:" + ui.StatusesCount;
            initialDetail();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            AMicroblog.Unfollow(ScreenName);
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void initialDetail()
        {
            lvStatusByName.GridLines = true;
            lvStatusByName.View = View.Details;
            lvStatusByName.LabelEdit = false;
            lvStatusByName.Scrollable = true;
            lvStatusByName.FullRowSelect = false;
            lvStatusByName.Columns.Add("CreateAt");
            lvStatusByName.Columns.Add("Text");
            foreach (StatusInfo status in AMicroblog.GetUserStatuses(AMicroblog.GetUserInfo(ScreenName).ID).Items)
            {
                ListViewItem lvi = new ListViewItem(new string[] { status.CreatedAt, status.Text });
                lvStatusByName.Items.Add(lvi);
            }
        }
    }
}
